#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main()
{
	int n;
	while (cin >> n)
	{
		vector<int>arr;
		int temp = n;
		while (temp)
		{
			arr.push_back(temp % 2);
			temp /= 2;
		}
		temp = arr[arr.size() - 1];
		arr.pop_back();
		arr.insert(arr.begin(), temp);
		int ans = 0;
		for (int i = 0,temp=1; i < arr.size(); i++,temp*=2)
		{
			if (arr[i])
				ans += temp;
		}
		cout << ans << endl;
	}
	return 0;
}
